#include <network\streamingClient.h>
#include <oglapp.h>

#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>

/*
#include <io\pngstream.h>
#include <iostream>
*/
int main(int argc, char* argv[]) {
/*
  unsigned short **rows = new unsigned short *[32];

  pngstream pngs;
  FILE *fin;
  //if (fopen_s(&fin, "D:\\Cadwork\\ddddstreaming_framework\\client\\client\\cache\\world\\jarek\\terrain_tiles\\1\\34\\541\\21\\725.png", "rb") == 0) {
  if (fopen_s(&fin, "D:\\streamingserverdb\\world\\global_profile\\terrain_tiles\\-2\\276\\230\\173\\279.png", "rb") == 0) {
  //if (fopen_s(&fin, "D:\\streamingserverdb\\world\\global_profile\\terrain_tiles\\-1\\138\\115\\86\\600.png", "rb") == 0) {
  //if (fopen_s(&fin, "D:\\streamingserverdb\\world\\global_profile\\terrain_tiles\\0\\69\\58\\43\\428.png", "rb") == 0) {
    pngs.initializeInput(fin, false);

    int row = 0;
    while(pngs.hasNext()) {
      rows[row++] = (unsigned short *) pngs.readLine();
    }

    pngs.finishInput();
    fclose(fin);
  }
  
  for (int y = 0; y != 32; y++) {
    for(int x = 0; x != 32; x++) {
      std::cout << y << " " << x << " " << rows[y][x] / 10.0 << std::endl;
    }
  }
*/
  

  streamingClient &client = streamingClient::instance();

  client.setCacheDir("cache");
  client.setConnection("localhost", "9000");
  client.setLogin("world", "jarek", "uriden0t");

  client.start();

  if (client.isInitialized()) {
    if (oglapp::instance().start(argc, argv)) {
      glutMainLoop();
    }

    client.stop();
  }

  client.destroy();

  return 0;
}
